<?php $this->headScript()->captureStart() ?>
$(document).ready(function(){
    var optionsLogin = { 
        type:"POST",
        dataType : "text",
        buttons:$('#loginForm').find("button[name='button']"),
        async : true,
        cache: false,
        success:function(responseText, statusText)
        {
            var json = jQuery.parseJSON(responseText);
            if(json.result != 1){
                dialogMessage(json.messages);
                $('#loginForm').find(".captcha").reloadCaptcha();
                return false;
            }
            
            dialogTipRedirect(json.messages, '<?php echo $this->baseUrl("");?>');
            return true;
        },
    };
    var v = jQuery("#loginForm").validate({
        debug: true,
        messages: {
            account: {
                required: "<?php echo $this->translate("Please enter a account.");?>",
            },
            password: {
                required: "<?php echo $this->translate("Please provide a password.");?>",
            },
        },
        rules: {
            account: {
                required: true,
            },
            password: {
                required: true,
            },
        },
        errorPlacement: function(error, element) {
            var elementName = element.attr("name");
            var idTip = 'tip-login-' + elementName;
            $("#" + idTip).html(error);
        },
        success: function(label) {
            label.addClass("valid").text("Ok!");
        },
        submitHandler: function(form) {
            jQuery(form).ajaxSubmit(optionsLogin);
        }
    });
    
    
    var optionsRegister = { 
        type:"POST",
        dataType : "text",
        buttons:$('#registerForm').find("button[name='button']"),
        async : true,
        cache: false,
        success:function(responseText, statusText)
        {
            var json = jQuery.parseJSON(responseText);
            if(json.result != 1){
                dialogMessage(json.messages);
                $('#registerForm').find(".captcha").reloadCaptcha();
                return false;
            }
            
            dialogTipRedirect(json.messages, '<?php echo $this->baseUrl("");?>');
            return true;
        },
    };
    var v = jQuery("#registerForm").validate({
        debug: true,
        messages: {
            username: {
                required: "<?php echo $this->translate("Please enter a username.");?>",
            },
            email: {
                required: "<?php echo $this->translate("Please enter a email.");?>",
                email: "<?php echo $this->translate("Please enter a valid email.");?>",
            },
            password: {
                required: "<?php echo $this->translate("Please provide a password.");?>",
                minlength: "<?php echo $this->translate("Your password must be at least 6 characters long.");?>",
            },
            confirmPassword: {
                required: "<?php echo $this->translate("Please provide a confirm password.");?>",
                minlength: "<?php echo $this->translate("Your confirm password must be at least 6 characters long.");?>",
                equalTo: "<?php echo $this->translate("Please enter the same password as above.");?>",
            },
            nickname: {
                required: "<?php echo $this->translate("Please enter a nickname.");?>",
            },
        },
        rules: {
            username: {
                required: true,
            },
            email: {
                required: true,
                email: true,
            },
            password: {
                required: true,
                minlength: 6,
            },
            confirmPassword: {
                required: true,
                minlength: 6,
                equalTo: "#registerForm #password",
            },
            nickname: {
                required: true,
            },
        },
        errorPlacement: function(error, element) {
            var elementName = element.attr("name");
            var idTip = 'tip-' + elementName;
            $("#" + idTip).html(error);
        },
        success: function(label) {
            label.addClass("valid").text("Ok!");
        },
        submitHandler: function(form) {
            jQuery(form).ajaxSubmit(optionsRegister);
        }
    });
});
<?php $this->headScript()->captureEnd() ?>

<div class="container">
    <div class="column span-11 colborder">
        <h3>
            <?php echo $this->translate("Already have a account? Please login.");?>
        </h3>
        <div class="prepend-top">
            <?php echo $this->formLogin;?>
        </div>
    </div>
    <div class="column span-11 last">
        <h3>
            <?php echo $this->translate("Not have a account? Please register.");?>
        </h3>
        <div class="prepend-top">
        <?php echo $this->formRegister;?>
        </div>
    </div>
 </div>

